package com.movie.ticket.sale.cinema.assembly.cinemaassembly.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.movie.ticket.sale.cinema.assembly.cinemaassembly.dao.CinemaMapper;
import com.movie.ticket.sale.cinema.assembly.cinemaassembly.dao.LikeMapper;
import com.movie.ticket.sale.cinema.assembly.cinemaassembly.info.*;
import com.movie.ticket.sale.cinema.assembly.cinemaassembly.service.CinemaService;
import com.movie.ticket.sale.moviecommon.model.TCinemaMovie;
import com.movie.ticket.sale.test.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@Slf4j
public class CinemaServiceImpl implements CinemaService {

    @Autowired
    private CinemaMapper cinemaMapper;

    @Autowired
    private LikeMapper likeMapper;


    private static final String CINEMA_CACHE_NAME="cinema_cache";


//    @Cacheable(cacheNames = "testCache",key = "#user.userId")
    @Override
    public User test(User user) {
        log.info("我新增调用到了service层");
        return user;
    }
//    @Cacheable(cacheNames = "testCache",key = "#id")
    @Override
    public User find(int id) {
        log.info("我查找调用到了service层");
        return null;
    }

    @Override
    public List<MovieAcountInfo> findMovieNameById(int cinemaId) {
        return cinemaMapper.findMovieNameById(cinemaId);
    }

    @Override
    public IPage<MovieOrderInfo> findTicketOrder(Page<MovieOrderInfo> page, int cinemaId, String tradeNuo) {
        return cinemaMapper.findTicketOrder(page, cinemaId, tradeNuo);
    }

    @Override
    public IPage<VipOrderInfo> findVipOrder(Page<VipOrderInfo> page, int cinemaId, String tradeNuo) {
        return cinemaMapper.findVipOrder(page, cinemaId, tradeNuo);
    }

    @Override
    public CinemaState findCinemaStateById(int cinemaId) {
        return cinemaMapper.findCinemaStateById(cinemaId);
    }

    @Override
    public IPage<MovieDataInfo> findAllMovies(Page<MovieDataInfo> page, String name) {
        return likeMapper.findAllMovies(page,name);
    }

    @Override
    public IPage<MovieDataInfo> findCinemaMovie(Page<MovieDataInfo> page, int cinemaId, String name) {
        return likeMapper.findCinemaMovie(page, cinemaId, name);
    }

    @Override
    public void pullMovie(TCinemaMovie tCinemaMovie) {
        cinemaMapper.pullMovie(tCinemaMovie);
    }

    @Override
    public List<CinemaMovieInfo> isExist(int movieId, int cinemaId) {
        return cinemaMapper.isExist(movieId, cinemaId);
    }

    @Override
    public MovieDataInfo findMovieById(int movieId) {
        return cinemaMapper.findMovieById(movieId);
    }

    @Override
    public void soldOutCinemaMovie(int movieId, int cinemaId) {
        cinemaMapper.soldOutCinemaMovie(movieId, cinemaId);
    }

    @Override
    public void putawayCinemaMovie(int movieId, int cinemaId) {
        cinemaMapper.putawayCinemaMovie(movieId, cinemaId);
    }

    @Override
    public IPage<AuditoriumInfo> findAuditorium(Page<AuditoriumInfo> page, int cinemaId, String type) {
        return likeMapper.findAuditorium(page, cinemaId, type);
    }

    @Override
    public void addAuditorium(AuditoriumInfo auditoriumInfo) {
        cinemaMapper.addAuditorium(auditoriumInfo);
    }

    @Override
    public AuditoriumInfo findAuditoriumById(int id) {
        return cinemaMapper.findAuditoriumById(id);
    }

    @Override
    public void updateAuditorium(AuditoriumInfo auditoriumInfo) {
        cinemaMapper.updateAuditorium(auditoriumInfo);
    }

    @Override
    public void addVip(VipInfo vipInfo) {
        cinemaMapper.addVip(vipInfo);
    }

    @Override
    public int findParentCinema(int cinemaId) {
        return cinemaMapper.findParentCinema(cinemaId);
    }

    @Override
    public IPage<VipInfo> findVip(Page<VipInfo> page, int cinemaId, Integer state) {
        return cinemaMapper.findVip(page, cinemaId, state);
    }

    @Override
    public void updateVip(VipInfo vip) {
        cinemaMapper.updateVip(vip);
    }

    @Override
    public void delVip(int id) {
        cinemaMapper.delVip(id);
    }

    @Override
    public List<UserInfo> isUse(int cinemaId,int auditoriumId) {
        return cinemaMapper.isUse(cinemaId,auditoriumId);
    }

    @Override
    public void addPlan(PeridInfo peridInfo) {
        cinemaMapper.addPlan(peridInfo);
    }

    @Override
    public IPage<PeridInfo> findPlan(Page<PeridInfo> page,int cinemaId, Integer state, Integer auditoriumId, Integer movieId) {
        return cinemaMapper.findPlan(page, cinemaId,state, auditoriumId, movieId);
    }

    @Override
    public void updatePlan(PeridInfo info) {
        cinemaMapper.updatePlan(info);
    }

    @Override
    public List<PeridStateInfo> findPeridState() {
        return cinemaMapper.findPeridState();
    }

    @Override
    public void updatePerid(int id, int state) {
        cinemaMapper.updatePerid(id,state);
    }

    @Override
    public void delPlan(int id) {
        cinemaMapper.delPlan(id);
    }

    @Override
    public CinemaInfo annualCost(int id) {
        return cinemaMapper.annualCost(id);
    }

    @Override
    public void updateCinemaData(int cinemaId, String tel, String name, String address, String service) {
        cinemaMapper.updateCinemaData(cinemaId, tel, name, address, service);
    }

    @Override
    public void updateCinemaFilePath(CinemaDataInfo cinemaDataInfo) {
        cinemaMapper.updateCinemaFilePath(cinemaDataInfo);
    }

    @Override
    public int findCinemaDataId(int cinemaId, int type) {
        return cinemaMapper.findCinemaDataId(cinemaId, type);
    }


    @Override
    public void closeCinema(int cinemaId) {
        cinemaMapper.closeCinema(cinemaId);
    }

    @Override
    public void signIn(String checkCode) {
        cinemaMapper.signIn(checkCode);
    }

    @Override
    public List<Integer> isSignIn(String checkCode) {
        return cinemaMapper.isSignIn(checkCode);
    }

    @Override
    public List<AutoOrderInfo> findAllOrder() {
        return cinemaMapper.findAllOrder();
    }

    @Override
    public int findperidState(int peridId) {
        return cinemaMapper.findperidState(peridId);
    }

    @Override
    public void finishOrder(int id, int state) {
        cinemaMapper.finishOrder(id, state);
    }

    @Override
    public void addBoxOffice(int id, double boxOffice) {
        cinemaMapper.addBoxOffice(id, boxOffice);
    }
}
